package com.galeno.redis;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * @author galeno
 * @Title:
 * @Description:
 * @date 2021/9/1422:44
 */
public class HLogLogAPI {
    public static void main(String[] args) {
        Jedis jedis = new JedisPool("galeno01", 6379).getResource();

        // 生成一个hyperloglog数据，并插入元素\
        jedis.flushDB();
        jedis.pfadd("hll", "a", "a", "b", "c");
        jedis.pfadd("hll2", "a", "a", "b", "e");

        // 查询基数
        long hll = jedis.pfcount("hll");
        System.out.println(hll);


        //合并多个hll数据
        String pfmerge = jedis.pfmerge("me", "hll", "hll2");
        System.out.println(pfmerge);
        System.out.println(jedis.pfcount("me"));
        jedis.close();


    }
}
